import { createRouter, createWebHashHistory } from 'vue-router'
export const routes = [
	{
		path: '/',
		component: () => import('@/pages/index.vue'),
		meta: {
			lable: '概览',
			icon: 'PieChartOutlined'
		}
	},
	{
		path: '/device',
		component: () => import('@/pages/device/index.vue'),
		meta: {
			lable: '设备管理',
			icon: 'AppstoreAddOutlined'
		},
		children: [
			{
				path: '/device/category',
				component: () => import('@/pages/device/category.vue'),
				meta: {
					lable: '产品分类',
				}
			},
			{
				path: '/device/list',
				component: () => import('@/pages/device/list.vue'),
				meta: {
					lable: '设备列表',
				}
			},
			{
				path: '/device/map',
				component: () => import('@/pages/device/map.vue'),
				meta: {
					lable: '设备分布',
				}
			},
		]

	},
	{
		path: '/gateways',
		component: () => import('@/pages/gateways/index.vue'),
		meta: {
			lable: '网关管理',
			icon: 'BoxPlotOutlined'
		},
		children: [
			{
				path: '/gateways/list',
				component: () => import('@/pages/gateways/list.vue'),
				meta: {
					lable: '网关列表',
				}
			},
		]
	},
	{
		path: '/dashboard',
		component: () => import('@/pages/dashboard/index.vue'),
		meta: {
			lable: '可视化',
			icon: 'AreaChartOutlined'
		},
		children: [
			{
				path: '/dashboard/dashboard',
				component: () => import('@/pages/dashboard/dashboard.vue'),
				meta: {
					lable: '卡片监控',
				}
			},
			{
				path: '/dashboard/map',
				component: () => import('@/pages/dashboard/map.vue'),
				meta: {
					lable: '地图监控',
				}
			},
		]
	},
	{
	    path: '/menu',
	    component: () => import('@/pages/menu/index.vue'),
	    meta: {
	        lable: '菜单管理',
	        icon: 'CopyOutlined'
	    },
	    children: [
	        {
	            path: '/menu/menu',
	            component: () => import('@/pages/menu/menu.vue'),
	            meta: {
	                lable: '菜单Mac',
	            }
	        },
	    ]
	},
	{
	    path: '/echarts',
	    component: () => import('@/pages/echarts/index.vue'),
	    meta: {
	        lable: '图表管理',
	        icon: 'CopyOutlined'
	    },
	    children: [
	        {
	            path: '/echarts/echarts',
	            component: () => import('@/pages/echarts/echarts.vue'),
	            meta: {
	                lable: '图表集',
	            }
	        },
	    ]
	},
]
const router = createRouter({
	history: createWebHashHistory(),
	routes
})
// router.beforeEach((to, from, next) => {
// 	if (localStorage.getItem('router_link')) {
// 		const link = JSON.parse(localStorage.getItem('router_link'))
// 		localStorage.removeItem('router_link')
// 		next(link)
// 	} else {
// 		next()
// 	}
// })
// router.afterEach((to, from) => {
// 	localStorage.setItem('router_link', JSON.stringify(to))
// })

export default router
